import { ecs } from "db://app-game/libs/ecs/ECS";
import { DBStaticCreature } from "../../../common/db/db-static-creature/DBStaticCreature";
import { DBStaticCreatureType } from "../../../common/db/db-static-creature/DBStaticCreature.type";
import { Node } from "cc";

/** 静态生物组件 */
@ecs.register("StaticModel")
export class StaticModelComp extends ecs.Comp {
  db: DBStaticCreature = new DBStaticCreature();
  _id: number = -1;
  /** 地图编号 */
  get id(): number {
    return this._id;
  }
  set id(value: number) {
    this._id = value;
    this.db.init(value);
    this.data = this.db.data;
  }

  /** 地图数据 */
  data: DBStaticCreatureType = null!;

  /** 静态生物节点 */
  node: Node = null!;

  /** 透明状态 */
  transparentState = false;
  reset(entity: ecs.Entity): void {
    this._id = -1;
    this.data = null!;
    this.node = null!;
    this.transparentState = false;
  }
}
